package net.xiangcaowuyu.mybatis.controller;

import net.xiangcaowuyu.mybatis.entity.Book;
import net.xiangcaowuyu.mybatis.service.BookService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author laughing
 * @date 2020-10-16
 */
@RestController
@RequestMapping("book")
public class BookController {

    private final BookService bookService;

    public BookController(BookService bookService){
        this.bookService=bookService;
    }

    /**
     * 查询book
     *
     * @param id 主键
     * @return book
     */
    @GetMapping("selectByPrimaryKey/{id}")
    public Book selectByPrimaryKey(@PathVariable("id") Integer id) {
        return bookService.selectByPrimaryKey(id);
    }

}
